package org.jimmy.tang.faces.beans;

import java.io.Serializable;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;

/**
 * @author jimmy
 * 
 */
@ManagedBean
@SessionScoped
public class HelloBean implements Serializable {

    private static final long serialVersionUID = 1L;

    private String name;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @ManagedProperty(value = "#{message}")
    private MessageBean messageBean;

    // must povide the setter method
    public void setMessageBean(MessageBean messageBean) {
        this.messageBean = messageBean;
    }

    public String getSayWelcome() {
        // check if null?
        if ("".equals(name) || (name == null)) {
            return "";
        } else {
            return "Ajax message : Welcome " + name;
        }
    }

}
